<?php

namespace app\admin\controller\order;

use app\admin\model\UM as UM;
use app\admin\service\TradeService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * Order 控制器
 * Class Order
 * @package app\admin\controller\order;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\admin\validate\order\Order
 */
class Order
{
    // 请求参数
    private Request $request;

    // service
    private TradeService $service;

    public function __construct(Request $request, TradeService $service)
    {
        $this->request = $request;
        $this->service = $service;
    }

    /**
     * 列表
     * @param UM $user
     * @return ApiResponse
     * @url /order/order/index
     */
    public function index(UM $user): ApiResponse
    {
        $request = $this->request;

        $memberId = $request->param('memberId');
        $provinceId = $request->param('provinceId');
        $cityId = $request->param('cityId');
        $payMethod = $request->param('payMethod');
        $categoryId = $request->param('categoryId');
        $serverId = $request->param('serverId');
        $status = $request->param('status');
        $startTime = $request->param('startTime');
        $endTime = $request->param('endTime');
        $kw = $request->param('kw');

        $page = $request->param('page', 1);
        $page_size = $request->param('page_size', 20);

        return ApiResponse::success($this->service->index($user, $memberId, $provinceId, $cityId, $payMethod, $categoryId, $serverId, $status, $startTime, $endTime, $kw, $page, $page_size));
    }

}
